package Oct_2020_BETA.part2;

import java.io.*;

public class IO {
    public static void main(String[] args) throws IOException {
        id1();
    }

    public static void id1() throws IOException {
        char temp;
//        参数可以是字符串、或是File对象
        InputStream in = new FileInputStream("F:\\wudao\\README.md");
        do {
            System.out.print((char) (in.read()));
        } while (in.read() != -1);
//        in.close();
//        Exception in thread "main" java.io.IOException: Stream Closed
//        in.read();
        BufferedInputStream bis=new BufferedInputStream(in);
        System.out.println((char)(bis.read()));
        bis.close();
        FileOutputStream fos=new FileOutputStream("F:\\wudao\\README.md",true);//设置为TRUE时可以追加
        fos.write(99);
//        fos.close();
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        bos.write(123);
        bos.flush();//将数据从out流里刷出去，刷到磁盘保存
        bos.close();//flush+close

    }
}
